package com.thrd.taiexhibition.adapter;

import android.content.Context;

import com.thrd.basicframework.bean.BaseRecyclerAdapter;
import com.thrd.taiexhibition.R;
import com.thrd.taiexhibition.bean.BeanStory;
import com.thrd.taiexhibition.bean.BeanStoryType;
import com.thrd.taiexhibition.ui.StoryLayout;

import java.util.List;

/**
 * @author: ${唐杰}
 * @date: 2021/3/10
 */
public class StoryAdapter extends BaseRecyclerAdapter<BeanStoryType> {
    public StoryAdapter(Context context, List<BeanStoryType> data) {
        super(context, data);
    }

    @Override
    public void bindData(final BaseViewHolder holder, BeanStoryType beanStoryType) {
        StoryLayout mStoryLayout= (StoryLayout) holder.getView(R.id.mStoryLayout);
        mStoryLayout.setOnClickDataListener(new StoryLayout.OnClickDataListener() {
            @Override
            public void setOnClickDataListener(BeanStory beanStory) {
                if(onClickBeanStory!=null){
                    onClickBeanStory.setOnClickBeanStory(beanStory);
                }
            }
        });
        mStoryLayout.initType(beanStoryType.getLayoutType(),beanStoryType.getStoryList());
    }

    @Override
    public int getItemLayoutId() {
        return R.layout.item_story;
    }


    private OnClickBeanStory onClickBeanStory;

    public OnClickBeanStory getOnClickBeanStory() {
        return onClickBeanStory;
    }

    public void setOnClickBeanStory(OnClickBeanStory onClickBeanStory) {
        this.onClickBeanStory = onClickBeanStory;
    }

    public interface OnClickBeanStory{
        void setOnClickBeanStory(BeanStory mBeanStory);
    }

}
